package com.hu.zhcc.shiro.controller;

import com.hu.zhcc.shiro.entity.tj.TMeals;
import com.hu.zhcc.shiro.entity.tj.TMealsType;
import com.hu.zhcc.shiro.service.Tj_TMealsService;
import com.hu.zhcc.shiro.service.Tj_TMealsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 膳食库 前端控制器
 * </p>
 *
 * @author tj
 * @since 2021-06-24
 */
@RestController
@RequestMapping("/tjtMeals")
public class TjTMealsController {
    @Autowired
    private Tj_TMealsService tj_tMealsService;//膳食库
    @Autowired
    private Tj_TMealsTypeService tjTMealsTypeService;//膳食类别
    //查询全部
    @GetMapping("/queryAll")
    public List<TMeals> queryAll(){
       return tj_tMealsService.queryAll();
    }
    //添加膳食库
    @PostMapping("")
    public int addTmeals(@RequestBody TMeals tMeals){
       return tj_tMealsService.addTmeals(tMeals);
    }
    //根据编号查询
    @GetMapping("/{id}")
    public TMeals queryById(@PathVariable("id") Integer id){
        System.out.println(id);
        return tj_tMealsService.queryById(id);
    }
    //修改膳食库
    @PutMapping("")
    public int updTmeals(@RequestBody TMeals tMeals){
        return tj_tMealsService.updTmeals(tMeals);
    }
    //查询膳食类别
    @GetMapping("/queryTmealsType")
    public List<TMealsType> queryAllType(){
       return tjTMealsTypeService.queryAll();
    }

}

